package com.onstar.cn.sqlite.entities;

import android.content.Context;

import com.onstar.cn.common.util.EncryptUtil;
import com.onstar.cn.sqlite.xutil.db.annotation.Column;
import com.onstar.cn.sqlite.xutil.db.annotation.Id;
import com.onstar.cn.sqlite.xutil.db.annotation.Table;
import com.onstar.cn.sqlite.xutil.db.annotation.Transient;

import java.io.Serializable;

@Table(name = "t_onstar_polling_status")
public class PollingEntity implements Serializable {
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    @Id
    @Column(column = "_id")
    private Integer id;
    @Column(column = "vin")
    private String vin;
    @Column(column = "requestStatus")
    private String requestStatus;
    @Column(column = "requestType")
    private String requestType;
    @Column(column = "requestId")
    private String requestId;
    @Column(column = "make")
    private String make;
    @Column(column = "model")
    private String model;
    @Column(column = "startTime")
    private String startTime;
    @Column(column = "endTime")
    private String endTime;
    @Column(column = "result")
    private long result;
    @Transient
    private String token;

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public long getResult() {
        return result;
    }

    public void setResult(long result) {
        this.result = result;
    }

    public Integer getId() {
        return id;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getVin() {
        return vin;
    }

    public void setVin(String vin) {
        this.vin = vin;
    }

    public String getRequestStatus() {
        return requestStatus;
    }

    public void setRequestStatus(String requestStatus) {
        this.requestStatus = requestStatus;
    }

    public String getRequestType() {
        return requestType;
    }

    public void setRequestType(String requestType) {
        this.requestType = requestType;
    }

    public String getRequestId() {
        return requestId;
    }

    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }

    public String getMake() {
        return make;
    }

    public void setMake(String make) {
        this.make = make;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public PollingEntity encrypt(Context context) {
        PollingEntity entity = new PollingEntity();
        entity.make = EncryptUtil.encrypt(context, make);
        entity.model = EncryptUtil.encrypt(context, model);
        entity.requestId = EncryptUtil.encrypt(context, requestId);
        entity.requestType = EncryptUtil.encrypt(context, requestType);
        entity.requestStatus = EncryptUtil.encrypt(context, requestStatus);
        entity.vin = EncryptUtil.encrypt(context, vin);
        entity.startTime = EncryptUtil.encrypt(context, startTime);
        entity.endTime = EncryptUtil.encrypt(context, endTime);
        return entity;
    }

    public PollingEntity decrypt(Context context) {
        PollingEntity entity = new PollingEntity();
        entity.make = EncryptUtil.decrypt(context, make, "make");
        entity.model = EncryptUtil.decrypt(context, model, "model");
        entity.requestId = EncryptUtil.decrypt(context, requestId, "requestId");
        entity.requestType = EncryptUtil.decrypt(context, requestType, "requestType");
        entity.requestStatus = EncryptUtil.decrypt(context, requestStatus, "requestStatus");
        entity.vin = EncryptUtil.decrypt(context, vin, "vin");
        entity.startTime = EncryptUtil.decrypt(context, startTime, "startTime");
        entity.endTime = EncryptUtil.decrypt(context, endTime, "endTime");
        return entity;
    }
}
